<template>
  <div class="content">
    <div class="title">
      <div class="text">
        <div class="font">上月设备检修率</div>
      </div>
    </div>
    <div class="echart">
      <div id="Device" style="width:100%;height:200px;" />
    </div>
  </div>
</template>

<script>
import { currentData } from '@/api/autonym'

export default {
  name: 'Device',
  data() {
    return {
      data: {
        sign: 0,
        total: 0
      }
    }
  },
  mounted() {
    // this.getDetail()
  },
  methods: {
    // 获取数据
    async getDetail() {
      const res = await currentData()
      if (res.code === 200) {
        if (res.data) {
          this.data = res.data
        }
        this.$nextTick(function() {
          this.drawPie()
        })
      }
    },
    drawPie() {
      const myChart = this.$echarts.init(document.getElementById('Device'))

      const option = {
        tooltip: {
          formatter: '{a} <br/>{b} : {c}%'
        },
        title: [
          {
            text: '检修率',
            // subtext: 12312 + '个',
            textStyle: {
              fontSize: 14,
              color: '#ffffff'
            },
            subtextStyle: {
              fontSize: 14,
              color: '#ffffff'
            },
            textAlign: 'center',
            x: '50%',
            y: '55%'
          }],
        series: [
          {
            name: '业务指标',
            type: 'gauge',
            detail: {
              formatter: '{value}%',
              offsetCenter: ['5%', '50%'],
              textStyle: {
                fontSize: 14,
                color: '#FFFFFF'
              }
            },
            min: 0,
            max: 300,
            radius: '100%',
            data: [{ value: 60 }],
            axisTick: {
              show: false
            },
            splitLine: {
              show: true,
              length: 15,
              lineStyle: {
                color: 'auto'
              }
            },
            axisLabel: {
              // 表盘上的刻度数值文字
              show: false
            },
            axisLine: {
              lineStyle: {
                width: 10,
                color: [
                  [0.66, '#3BA0FF'],
                  [1, '#313032']
                ]
              }
            },
            pointer: {
              show: true,
              width: '3',
              length: '60%'
            },

            itemStyle: {
              color: '#3BA0FF',
              borderWidth: 5
            }
          },
          {
            // 指针外环
            type: 'pie',
            hoverAnimation: false,
            legendHoverLink: false,
            radius: ['5%', '10%'],
            z: 10,
            label: {
              normal: {
                show: false
              }
            },
            labelLine: {
              normal: {
                show: false
              }
            },
            data: [
              {
                value: 100,
                itemStyle: {
                  normal: {
                    color: '#3BA0FF'
                  }
                }
              }
            ]
          },
          {
            // 指针内环
            type: 'pie',
            hoverAnimation: false,
            legendHoverLink: false,
            radius: ['0%', '5%'],
            z: 10,
            label: {
              normal: {
                show: false
              }
            },
            labelLine: {
              normal: {
                show: false
              }
            },
            data: [
              {
                value: 100,
                itemStyle: {
                  normal: {
                    color: '#313032'
                  }
                }
              }
            ]
          }
        ]
      }
      myChart.setOption(option, window.onresize = myChart.resize)
    }
  }
}
</script>

<style lang="scss" scoped>
.content{
  // color: #ffffff;
  // border: 1px solid rgba(221,221,221,0.2);
  margin: 0;
  padding: 10px;
  .title{
    display: flex;
    .text{
      flex: 1;
      text-align: left;
      .font{
        color:#ffffff;
        cursor: pointer;
        font-size: 12px;
        font-weight: 400;
        padding: 5px 0;
        .number{
          font-size:14px;
          font-weight:500;
          color:rgba(255,255,255,0.85);
        }
      }
      .money{
         font-size: 12px;
        font-weight: 400;
        color: #ffffff;
      }
    }
  }
  .echart{
    // height: 70px;
    margin: 64px 0 0 0;
  }
  .name{
    margin-top: -60px;
    text-align: center;
    color:rgba(255,255,255,1);
    .text{
      text-align: center;
      margin-bottom: 6px;
      .bground{
        width:8px;
        height:8px;
        background:rgba(210,154,0,1);
        border-radius: 4px;
        float: left;
        margin-left: 27%;
        margin-top: 5px;
      }
    }
  }
}
</style>
